<?php

namespace app\api\behavior;

use think\Db;

// 记录 运行时间
class Timecost
{
    public function appInit(&$params)
    {
        // $GLOBALS['_begin_time'] = microtime(true);
    }

    public function appEnd(&$params)
    {
        // if ($GLOBALS['_begin_time']) {
        //     $timecost = round(microtime(true) - $GLOBALS['_begin_time'], 4);
        //     if ($timecost > 1) {
        //         $controller = strtolower(request()->controller());
        //         $action = strtolower(request()->action());
        //         $row = ['ct' => time(), 'url' => $controller.'/'.$action, 'in' => json_encode(input('param.', '')),  'timecost' => $timecost];
        //         Db::name('time_cost')->insert($row);
        //     }
        // }
    }
}
